home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Garbo
/
Garbo.cdr
/
mac
/
hypercrd
/
hc2_x
/
regnpckg.sit
/
BitMapToRegion ƒ
/
BMTR Patcher.c
< prev
next >
Wrap
Text File
|
1990-12-10
|
3KB
|
159 lines
/* Multi-purpose BMTR Installer
Written by Nigel Perry, 1990. This is in the PUBLIC DOMAIN.
Define INIT to use the source in the BMTR Init ╣.
Define XCMD for the BMTR XCMD ╣.
Define neither for the BMTR Patcher ╣.
CHECK the defines before compiling, there is only ONE
copy of this source file. The projects that use it have
different project types and different ╣.rsrc files.
*/
/*#define INIT*/ /* compile as INIT */
#define XCMD /* compile as XCMD */
#ifdef XCMD
#include <HyperXCmd.h>
/* from LSC 2.01 supplement */
#define SetUpA4() asm \
{ move.l a4,-(sp) \
move.l a0,a4 \
}
#define RestoreA4() asm { move.l (sp)+,a4 }
#endif
#define _BitMapToRegion 0xA8D7
#define _Unimplemented 0xA89F
#define NIL ((void *)0)
#define EMPTY ((char *)0xA02) /* low memory global OneOne */
/* used for "" and "\p" */
/* struct to match patch header */
typedef struct
{ int bra_instr;
long check1, check2;
} cheader;
#ifdef XCMD
pascal main(paramPtr) XCmdPtr paramPtr;
#else
main()
#endif
{ register Ptr UNIMPLaddr;
register cheader *patch, **hp;
#ifdef XCMD
Handle h;
register long ans;
#else
#ifndef INIT
/* patcher */
Str255 msg;
register msgnum;
#endif
#endif
#ifdef XCMD
SetUpA4();
#else
#ifndef INIT
/* patcher, use only in Finder */
InitGraf(&thePort);
InitFonts();
FlushEvents(everyEvent,0);
InitWindows();
InitMenus();
TEInit();
InitDialogs(NIL);
InitCursor();
if( CautionAlert(2, NIL) == 1 ) return;
#endif
#endif
asm
{ move.w #_Unimplemented,d0
_GetTrapAddress
move.l a0,UNIMPLaddr
move.w #_BitMapToRegion,d0
_GetTrapAddress NEWTOOL
cmp.l a0,UNIMPLaddr
#ifdef INIT
bne.s @systemTrap
#else
beq.s @patchit
cmp.l #'np90',OFFSET(cheader,check1)(a0)
bne.s @systemTrap
cmp.l #'juri',OFFSET(cheader,check2)(a0)
bne.s @systemTrap
#ifndef XCMD
; our trap - remove it
_RecoverHandle SYS
_DisposHandle
move.l UNIMPLaddr,a0
move.w #_BitMapToRegion,d0
_SetTrapAddress NEWTOOL
moveq #2,msgnum
#else
move.l #'woz\0',ans
#endif
bra.s @display
patchit:
#endif
}
hp = (cheader **)GetNamedResource('TRAP', "\pBitMapToRegion");
DetachResource((Handle)hp);
asm
{ move.l hp,a0
_MoveHHi ; move to top of heap
_HLock ; and lock it down
; SetTrapAddress(_BitMapToRegion, StripAddress(*hp))
move.l (a0),d0
_StripAddress
move.l d0,a0
move.w #_BitMapToRegion,d0
_SetTrapAddress NEWTOOL
#ifndef INIT
#ifdef XCMD
move.l #'add\0',ans
#else
moveq #1,msgnum
#endif
bra.s @display
#endif
}
systemTrap:
#ifdef XCMD
ans = 'sys\0';
display:
asm
{ moveq #4,d0
_NewHandle
move.l a0,h
move.l (a0),a0
move.l ans,(a0)
}
paramPtr->returnValue = h;
#else
#ifndef INIT
msgnum = 3;
display:
GetIndString(msg, 1, msgnum);
ParamText(msg, EMPTY, EMPTY, EMPTY);
NoteAlert(1, NIL);
#else
; /* INIT -> something must come after systemTrap label */
#endif
#endif
#ifdef XCMD
RestoreA4();
#endif
}